//
//  CardCreditOptions.m
//  
//
//  Created by barak on 10/27/12.
//  Copyright (c) 2012 yaniv. All rights reserved.
//

#import "CardCreditOptions.h"

@implementation CardCreditOptions

@synthesize creditAvailable;
@synthesize creditLimit;
@synthesize interestRate;
@synthesize totalDebt;

+ (CardCreditOptions *)instanceFromDictionary:(NSDictionary *)aDictionary {

    CardCreditOptions *instance = [[CardCreditOptions alloc] init];
    [instance setAttributesFromDictionary:aDictionary];
    return instance;

}

- (void)setAttributesFromDictionary:(NSDictionary *)aDictionary {

    if (![aDictionary isKindOfClass:[NSDictionary class]]) {
        return;
    }

    [self setValuesForKeysWithDictionary:aDictionary];

}

- (NSDictionary *)dictionaryRepresentation {

    NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];

    if (self.creditAvailable) {
        [dictionary setObject:self.creditAvailable forKey:@"creditAvailable"];
    }

    if (self.creditLimit) {
        [dictionary setObject:self.creditLimit forKey:@"creditLimit"];
    }

    if (self.interestRate) {
        [dictionary setObject:self.interestRate forKey:@"interestRate"];
    }

    if (self.totalDebt) {
        [dictionary setObject:self.totalDebt forKey:@"totalDebt"];
    }

    return dictionary;

}

@end
